import java.util.Stack;

class xin1 {

    Stack<Integer> StackIn;
    Stack<Integer>  StackOut;

    public void MyQueue() {
        StackIn = new Stack<>();
        StackOut = new Stack<>();
    }

    public void push(int x) {
        StackIn.push(x);
    }

    public int pop() {
        dumpStackIn();
        return StackOut.pop();
    }

    public int peek() {
        dumpStackIn();
        return StackOut.peek();
    }

    // 如果stackOut为空，那么将stackIn中的元素全部放到stackOut中
    public void dumpStackIn(){
        if(!StackOut.isEmpty()) return;
        while(!StackIn.isEmpty()){
            StackOut.push(StackIn.pop());
        }
    }

    public boolean empty() {
        return StackIn.isEmpty() && StackOut.isEmpty();
    }


}

/**
 * Your MyQueue object will be instantiated and called as such:
 * MyQueue obj = new MyQueue();
 * obj.push(x);
 * int param_2 = obj.pop();
 * int param_3 = obj.peek();
 * boolean param_4 = obj.empty();
 */